package com.school.controller;


import com.school.domain.dto.order.OrderAddDTO;
import com.school.domain.dto.order.SelectOrderDTO;
import com.school.domain.dto.order.UpdateOrderDTO;
import com.school.domain.po.Order;
import com.school.domain.vo.PageVO;
import com.school.domain.vo.Result;
import com.school.domain.vo.order.LargeScreenShowVO;
import com.school.domain.vo.order.OrderDetailsVO;
import com.school.service.OrderService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 订单主表 前端控制器
 * </p>
 *
 * @author Forever
 * @since 2025-07-05
 */
@RestController
@RequestMapping("/order")
@Tag(name = "订单主表接口")
public class OrderController {
    @Resource
    private OrderService orderService;

    @Operation(summary = "新增订单")
    @PostMapping("/addOrder")
    public Result<String> addOrder(@RequestBody OrderAddDTO orderAddDTO) {
        return Result.success(orderService.saveAddDTO(orderAddDTO));
    }

    @Operation(summary = "修改订单")
    @PostMapping("/updateOrder")
    public Result<String> updateOrder(@RequestBody UpdateOrderDTO updateOrderDTO) {
        return Result.success(orderService.updateOrder(updateOrderDTO));
    }

    @Operation(summary = "删除订单")
    @GetMapping("/deleteOrder/{orderId}")
    public Result<String> deleteOrder(@PathVariable Long orderId) {
        return Result.success(orderService.deleteOrder(orderId));
    }

    @Operation(summary = "查询订单")
    @PostMapping("/queryOrder")
    public Result<PageVO<Order>> queryOrder(@RequestBody SelectOrderDTO selectOrderDTO) {
        return Result.success(orderService.queryOrder(selectOrderDTO));
    }

    @Operation(summary = "查询订单明细")
    @PostMapping("/queryOrderDetail/{orderId}")
    public Result<List<OrderDetailsVO>> queryOrderDetail(@PathVariable Long orderId) {
        return Result.success(orderService.getOrderDetails(orderId));
    }

    @Operation(summary = "查询大屏订单数据")
    @PostMapping("/queryOrderData")
    public Result<LargeScreenShowVO> queryOrderData(@RequestParam String yearMonth) {
        return Result.success(orderService.queryLargeScreenData(yearMonth));
    }


}

